#/bin/bash

sudo ps -ef | grep  auto.sh | grep -v 'grep' | awk '{print $2}'| xargs kill -9

cd /home/pi
if ping gitee.com -c 1
then
    if rm -rf pipaper
    then
        if git clone https://gitee.com/windnbike/pipaper
        then
            sudo sed -i '/pipaper/d' /etc/rc.local
            sudo sed -i 's/"exit 0"/"Cross the wall, we can reach every corner of the world"/' /etc/rc.local
            sudo sed -i '/exit 0/i sudo /home/pi/pipaper/script/auto.sh&' /etc/rc.local
            sudo sed -i 's/"Cross the wall, we can reach every corner of the world"/"exit 0"/' /etc/rc.local
            sudo reboot
        fi
    fi
fi
sudo shutdown -h 300
